home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-20 | 51.2 KB | 2,106 lines |
- *** 1.5 1992/06/08 20:42:41
- --- Changelo 1992/07/20 22:22:32
- ***************
- *** 241,243 ****
- --- 241,254 ----
- addition of stossc() to streambufs for ATT compatibility.
-
- ---------------------------- Patchlevel 12 -----------------------------------
- +
- + all over:
- + sync up with libg++ 2.1.9. lots of bug fixes, more accurate floating
- + point i/o. this is not such a big deal for the atari.
- +
- + ---------------------------- Patchlevel 12.5 (not released) ------------------
- +
- + all over:
- + sync up with libg++ 2.2. very minor bug fixes over libg++ 2.1.9
- +
- + ---------------------------- Patchlevel 13 -----------------------------------
- *** 1.7 1992/06/08 20:42:41
- --- PatchLev.h 1992/07/20 22:22:32
- ***************
- *** 1,5 ****
-
- ! #define PatchLevel "12"
-
- /*
- * the Patch Level above is to identify the version
- --- 1,5 ----
-
- ! #define PatchLevel "13"
-
- /*
- * the Patch Level above is to identify the version
- *** 1.6 1992/06/08 20:42:41
- --- filebuf.cc 1992/07/20 22:22:35
- ***************
- *** 65,70 ****
- --- 65,73 ----
- // UNBUFFERED STREAMS:
- // If a filebuf is unbuffered(), the _shortbuf[1] is used as the buffer.
-
- + #define CLOSED_FILEBUF_FLAGS \
- + (_S_IS_FILEBUF+_S_NO_READS+_S_NO_WRITES+_S_TIED_PUT_GET)
- +
- void filebuf::init()
- {
- _fb._offset = 0;
- ***************
- *** 97,115 ****
- }
-
-
- ! filebuf::filebuf() : backupbuf(_S_IS_FILEBUF+_S_NO_READS+_S_NO_WRITES)
- {
- init();
- }
-
- ! filebuf::filebuf(int fd) : backupbuf(_S_IS_FILEBUF+_S_NO_READS+_S_NO_WRITES)
- {
- init();
- attach(fd);
- }
-
- ! filebuf::filebuf(int fd, char* p, size_t len)
- ! : backupbuf(_S_IS_FILEBUF+_S_NO_READS+_S_NO_WRITES)
- {
- init();
- attach(fd);
- --- 100,117 ----
- }
-
-
- ! filebuf::filebuf() : backupbuf(CLOSED_FILEBUF_FLAGS)
- {
- init();
- }
-
- ! filebuf::filebuf(int fd) : backupbuf(CLOSED_FILEBUF_FLAGS)
- {
- init();
- attach(fd);
- }
-
- ! filebuf::filebuf(int fd, char* p, size_t len) : backupbuf(CLOSED_FILEBUF_FLAGS)
- {
- init();
- attach(fd);
- ***************
- *** 139,145 ****
- #endif
- if ((mode & (ios::in|ios::out)) == (ios::in|ios::out)) {
- posix_mode = O_RDWR;
- ! read_write = _S_TIED_PUT_GET;
- }
- else if (mode & (ios::out|ios::app))
- posix_mode = O_WRONLY, read_write = _S_NO_READS;
- --- 141,147 ----
- #endif
- if ((mode & (ios::in|ios::out)) == (ios::in|ios::out)) {
- posix_mode = O_RDWR;
- ! read_write = 0;
- }
- else if (mode & (ios::out|ios::app))
- posix_mode = O_WRONLY, read_write = _S_NO_READS;
- ***************
- *** 165,173 ****
- else if(mode & (int)ios::text)
- rw_mode &= ~_S_IS_BINARY;
- read_write |= rw_mode;
- ! xsetflags(read_write, (_S_NO_READS+_S_NO_WRITES+_S_TIED_PUT_GET)|rw_mode);
- #else
- ! xsetflags(read_write, _S_NO_READS+_S_NO_WRITES+_S_TIED_PUT_GET);
- #endif
- if (mode & ios::ate) {
- if (seekoff(0, ios::end) == EOF)
- --- 167,175 ----
- else if(mode & (int)ios::text)
- rw_mode &= ~_S_IS_BINARY;
- read_write |= rw_mode;
- ! xsetflags(read_write, (_S_NO_READS+_S_NO_WRITES)|rw_mode);
- #else
- ! xsetflags(read_write, _S_NO_READS+_S_NO_WRITES);
- #endif
- if (mode & ios::ate) {
- if (seekoff(0, ios::end) == EOF)
- ***************
- *** 216,222 ****
- }
- if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) {
- omode = O_RDWR;
- ! read_write = _S_TIED_PUT_GET;
- }
- int fdesc = ::open(filename, omode|oflags, oprot);
- if (fdesc < 0)
- --- 218,224 ----
- }
- if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) {
- omode = O_RDWR;
- ! read_write = 0;
- }
- int fdesc = ::open(filename, omode|oflags, oprot);
- if (fdesc < 0)
- ***************
- *** 224,232 ****
- _fb._fileno = fdesc;
- #ifdef atarist
- read_write |= rw_mode;
- ! xsetflags(read_write, (_S_NO_READS+_S_NO_WRITES+_S_TIED_PUT_GET)|rw_mode);
- #else
- ! xsetflags(read_write, _S_NO_READS+_S_NO_WRITES+_S_TIED_PUT_GET);
- #endif
- _link_in();
- return this;
- --- 226,234 ----
- _fb._fileno = fdesc;
- #ifdef atarist
- read_write |= rw_mode;
- ! xsetflags(read_write, (_S_NO_READS+_S_NO_WRITES)|rw_mode);
- #else
- ! xsetflags(read_write, _S_NO_READS+_S_NO_WRITES);
- #endif
- _link_in();
- return this;
- ***************
- *** 253,267 ****
- if (xflags() & _S_NO_WRITES) // SET ERROR
- return EOF;
- // Allocate a buffer if needed.
- ! if (pbase() == NULL) {
- ! if (base() == NULL)
- ! doallocbuf();
- ! if (xflags() & _S_LINE_BUF+_S_UNBUFFERED) setp(base(), base());
- ! else setp(base(), ebuf());
- ! setg(pbase(), pbase(), pbase());
- }
- // If currently reading, switch to writing.
- ! if ((_flags & _S_TIED_PUT_GET+_S_CURRENTLY_PUTTING) == _S_TIED_PUT_GET) {
- if (xflags() & _S_LINE_BUF+_S_UNBUFFERED) setp(gptr(), gptr());
- else setp(gptr(), ebuf());
- setg(egptr(), egptr(), egptr());
- --- 255,269 ----
- if (xflags() & _S_NO_WRITES) // SET ERROR
- return EOF;
- // Allocate a buffer if needed.
- ! if (base() == NULL) {
- ! doallocbuf();
- ! if (xflags() & _S_LINE_BUF+_S_UNBUFFERED) setp(_base, _base);
- ! else setp(_base, _ebuf);
- ! setg(_base, _base, _base);
- ! _flags |= _S_CURRENTLY_PUTTING;
- }
- // If currently reading, switch to writing.
- ! else if ((_flags & _S_CURRENTLY_PUTTING) == 0) {
- if (xflags() & _S_LINE_BUF+_S_UNBUFFERED) setp(gptr(), gptr());
- else setp(gptr(), ebuf());
- setg(egptr(), egptr(), egptr());
- ***************
- *** 269,275 ****
- }
- if (c == EOF)
- return do_flush();
- ! if (pptr() == ebuf()) // Buffer is really full
- if (do_flush() == EOF)
- return EOF;
- xput_char(c);
- --- 271,277 ----
- }
- if (c == EOF)
- return do_flush();
- ! if (pptr() == ebuf() ) // Buffer is really full
- if (do_flush() == EOF)
- return EOF;
- xput_char(c);
- ***************
- *** 311,316 ****
- --- 313,319 ----
- xsetflags(_S_ERR_SEEN), count = 0;
- }
- setg(base(), base(), base() + count);
- + setp(base(), base());
- if (count == 0)
- return EOF;
- if (_fb._offset >= 0)
- ***************
- *** 318,326 ****
- return *(unsigned char*)gptr();
- }
-
- ! int filebuf::do_flush()
- {
- - long to_do = pptr()-pbase();
- if (to_do == 0)
- return 0;
- if (egptr() != pbase()) {
- --- 321,328 ----
- return *(unsigned char*)gptr();
- }
-
- ! int filebuf::do_write(const char *data, int to_do)
- {
- if (to_do == 0)
- return 0;
- if (egptr() != pbase()) {
- ***************
- *** 329,337 ****
- return EOF;
- _fb._offset = new_pos;
- }
- ! _G_ssize_t count = sys_write(pbase(), to_do);
- if (_cur_column)
- ! _cur_column = __adjust_column(_cur_column - 1, pbase(), to_do) + 1;
- if (count != to_do)
- return EOF;
- setg(base(), base(), base());
- --- 331,339 ----
- return EOF;
- _fb._offset = new_pos;
- }
- ! _G_ssize_t count = sys_write(data, to_do);
- if (_cur_column)
- ! _cur_column = __adjust_column(_cur_column - 1, data, to_do) + 1;
- if (count != to_do)
- return EOF;
- setg(base(), base(), base());
- ***************
- *** 377,384 ****
- if (pptr() > pbase() || put_mode())
- if (switch_to_get_mode()) return EOF;
-
- ! allocbuf();
- ! // FIXME: Will this work if get and put areas are NULL?
- switch (dir) {
- case ios::cur:
- if (_fb._offset < 0) {
- --- 379,389 ----
- if (pptr() > pbase() || put_mode())
- if (switch_to_get_mode()) return EOF;
-
- ! if (base() == NULL) {
- ! doallocbuf();
- ! setp(base(), base());
- ! setg(base(), base(), base());
- ! }
- switch (dir) {
- case ios::cur:
- if (_fb._offset < 0) {
- ***************
- *** 460,465 ****
- --- 465,471 ----
- }
- }
- setg(base(), base()+delta, base()+count);
- + setp(base(), base());
- _fb._offset = result + count;
- xflags(xflags() & ~ _S_EOF_SEEN);
- return offset;
- ***************
- *** 494,500 ****
- setp(NULL, NULL);
-
- _un_link();
- ! _flags = _IO_MAGIC | _S_IS_FILEBUF | _S_NO_READS | _S_NO_WRITES;
- _fb._fileno = EOF;
- _fb._offset = 0;
-
- --- 500,506 ----
- setp(NULL, NULL);
-
- _un_link();
- ! _flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS;
- _fb._fileno = EOF;
- _fb._offset = 0;
-
- ***************
- *** 503,509 ****
-
- _G_ssize_t filebuf::sys_read(char* buf, size_t size)
- {
- ! return ::read(_fb._fileno, buf, size);
- }
-
- fpos_t filebuf::sys_seek(fpos_t offset, _seek_dir dir)
- --- 509,519 ----
-
- _G_ssize_t filebuf::sys_read(char* buf, size_t size)
- {
- ! for (;;) {
- ! _G_ssize_t count = ::read(_fb._fileno, buf, size);
- ! if (count != -1 || errno != EINTR)
- ! return count;
- ! }
- }
-
- fpos_t filebuf::sys_seek(fpos_t offset, _seek_dir dir)
- ***************
- *** 516,523 ****
- long to_do = n;
- while (to_do > 0) {
- _G_ssize_t count = ::write(fd(), buf, to_do);
- ! if (count == EOF)
- ! break;
- to_do -= count;
- buf += count;
- }
- --- 526,537 ----
- long to_do = n;
- while (to_do > 0) {
- _G_ssize_t count = ::write(fd(), buf, to_do);
- ! if (count == EOF) {
- ! if (errno == EINTR)
- ! continue;
- ! else
- ! break;
- ! }
- to_do -= count;
- buf += count;
- }
- ***************
- *** 539,544 ****
- --- 553,560 ----
-
- size_t filebuf::sputn(const char *s, size_t n)
- {
- + if (n <= 0)
- + return 0;
- // This is an optimized implementation.
- // If the amount to be written straddles a block boundary
- // (or the filebuf is unbuffered), use sys_write directly.
- ***************
- *** 567,599 ****
-
- // Try to maintain alignment: write a whole number of blocks.
- // dont_write is what gets left over.
- ! int block_size = _epptr - _pbase;
- int dont_write = block_size >= 128 ? to_do % block_size : 0;
-
- ! _G_ssize_t written = sys_write(s, to_do - dont_write);
- ! if (_cur_column)
- ! _cur_column = 1 + __adjust_column(_cur_column - 1,
- ! s, to_do-dont_write);
- !
- ! s += written;
- ! to_do -= written;
- ! if (to_do != dont_write)
- return n - to_do;
-
- ! count = _epptr - _pptr; // Space available.
- ! // Write out the remainder, if any.
- ! if (count > to_do)
- ! count = to_do;
- ! if (count > 20) {
- ! memcpy(pptr(), s, count);
- ! s += count;
- ! }
- ! else {
- ! register char *p = pptr();;
- ! for (register int i = count; --i >= 0; ) *p++ = *s++;
- ! }
- ! pbump(count);
- ! to_do -= count;
- }
- return n - to_do;
- }
- --- 583,601 ----
-
- // Try to maintain alignment: write a whole number of blocks.
- // dont_write is what gets left over.
- ! int block_size = _ebuf - _base;
- int dont_write = block_size >= 128 ? to_do % block_size : 0;
-
- ! _G_ssize_t count = to_do - dont_write;
- ! if (do_write(s, count) == EOF)
- return n - to_do;
- + to_do = dont_write;
-
- ! // Now write out the remainder. Normally, this will fit in the
- ! // buffer, but it's somewhat messier for line-buffered files,
- ! // so we let streambuf::sputn handle the general case.
- ! if (dont_write)
- ! to_do -= streambuf::sputn(s+count, dont_write);
- }
- return n - to_do;
- }
- *** 1.2 1992/06/03 02:12:17
- --- fstream.cc 1992/07/20 22:22:35
- ***************
- *** 37,43 ****
- _strbuf = new filebuf();
- if (!rdbuf()->open(name, mode, prot))
- set(ios::badbit);
- - _flags &= ~ios::dont_close;
- }
-
- ofstream::ofstream()
- --- 37,42 ----
- ***************
- *** 55,61 ****
- _strbuf = new filebuf();
- if (!rdbuf()->open(name, mode, prot))
- set(ios::badbit);
- - _flags &= ~ios::dont_close;
- }
-
- #if 0
- --- 54,59 ----
- ***************
- *** 107,113 ****
- _strbuf = new filebuf();
- if (!rdbuf()->open(name, mode, prot))
- set(ios::badbit);
- - _flags &= ~ios::dont_close;
- }
-
- void fstream::open(const char *name, int mode, int prot=0664)
- --- 105,110 ----
- *** 1.1 1992/03/22 07:42:32
- --- gnuaux.c 1992/07/20 22:22:35
- ***************
- *** 83,93 ****
- return __set_new_handler (handler);
- }
-
- static void
- default_new_handler ()
- {
- /* don't use fprintf (stderr, ...) because it may need to call malloc. */
- ! write (2, "default_new_handler: out of memory... aaaiiiiiieeeeeeeeeeeeee!\n", 65);
- /* don't call exit () because that may call global destructors which
- may cause a loop. */
- _exit (-1);
- --- 83,94 ----
- return __set_new_handler (handler);
- }
-
- + #define MESSAGE "default_new_handler: out of memory... aaaiiiiiieeeeeeeeeeeeee!\n"
- static void
- default_new_handler ()
- {
- /* don't use fprintf (stderr, ...) because it may need to call malloc. */
- ! _write (2, MESSAGE, sizeof(MESSAGE));
- /* don't call exit () because that may call global destructors which
- may cause a loop. */
- _exit (-1);
- *** 1.2 1992/06/03 02:12:17
- --- igetline.cc 1992/07/20 22:22:36
- ***************
- *** 80,88 ****
- long old_total = total;
- total += count;
- if (ch != EOF && ch != terminator) {
- ptr = _sb_readline(sb, total, terminator);
- ! if (ptr)
- memcpy(ptr + old_total, buf, count);
- return ptr;
- }
-
- --- 80,91 ----
- long old_total = total;
- total += count;
- if (ch != EOF && ch != terminator) {
- + total++; // Include ch in total.
- ptr = _sb_readline(sb, total, terminator);
- ! if (ptr) {
- memcpy(ptr + old_total, buf, count);
- + ptr[old_total+count] = ch;
- + }
- return ptr;
- }
-
- *** 1.6 1992/06/08 20:42:41
- --- iostream.cc 1992/07/20 22:22:37
- ***************
- *** 31,58 ****
-
- extern backupbuf not_open_filebuf;
-
- ! istream::istream() : ios(¬_open_filebuf)
- {
- _flags |= ios::dont_close;
- _gcount = 0;
- - _tie = NULL;
- }
-
- - istream::istream(streambuf *sb, ostream* tied) : ios(sb)
- - {
- - _flags |= ios::dont_close;
- - _gcount = 0;
- - _tie = tied;
- - }
- -
- - istream::~istream()
- - {
- - if (!(_flags & (unsigned int)ios::dont_close))
- - delete _strbuf;
- - _flags |= ios::dont_close;
- - _strbuf = ¬_open_filebuf;
- - }
- -
- int skip_ws(streambuf* sb)
- {
- int ch;
- --- 31,42 ----
-
- extern backupbuf not_open_filebuf;
-
- ! istream::istream(streambuf *sb, ostream* tied) : ios(sb, tied)
- {
- _flags |= ios::dont_close;
- _gcount = 0;
- }
-
- int skip_ws(streambuf* sb)
- {
- int ch;
- ***************
- *** 140,146 ****
- if (ipfx0()) {
- va_list ap;
- va_start(ap, format);
- ! _strbuf->vscan(format, ap);
- va_end(ap);
- }
- return *this;
- --- 124,130 ----
- if (ipfx0()) {
- va_list ap;
- va_start(ap, format);
- ! _strbuf->vscan(format, ap, &_state);
- va_end(ap);
- }
- return *this;
- ***************
- *** 149,155 ****
- istream& istream::vscan(const char *format, _G_va_list args)
- {
- if (ipfx0())
- ! _strbuf->vscan(format, args);
- return *this;
- }
-
- --- 133,139 ----
- istream& istream::vscan(const char *format, _G_va_list args)
- {
- if (ipfx0())
- ! _strbuf->vscan(format, args, &_state);
- return *this;
- }
-
- ***************
- *** 254,266 ****
- digit = ch - 'a' + 10;
- else
- digit = 999;
- ! if (digit >= base)
- if (ndigits == 0)
- goto fail;
- ! else {
- ! sb->sputbackc(ch);
- return 1;
- ! }
- ndigits++;
- val = base * val + digit;
- ch = sb->sbumpc();
- --- 238,250 ----
- digit = ch - 'a' + 10;
- else
- digit = 999;
- ! if (digit >= base) {
- ! sb->sputbackc(ch);
- if (ndigits == 0)
- goto fail;
- ! else
- return 1;
- ! }
- ndigits++;
- val = base * val + digit;
- ch = sb->sbumpc();
- ***************
- *** 369,375 ****
- int buf_len = strlen(buf);
- int w = stream.width(0);
- int show_pos = 0;
- - int i;
-
- // Calculate padding.
- int len = buf_len;
- --- 353,358 ----
- ***************
- *** 380,400 ****
-
- // Do actual output.
- register streambuf* sbuf = stream.rdbuf();
- ! unsigned long pad_kind =
- stream.flags() & (ios::left|ios::right|ios::internal);
- char fill_char = stream.fill();
- ! if (pad_kind != (unsigned long)ios::left // Default (right) adjustment.
- ! && pad_kind != (unsigned long)ios::internal)
- ! for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
- if (neg) sbuf->sputc('-');
- else if (show_pos) sbuf->sputc('+');
- if (show_base_len)
- sbuf->sputn(show_base, show_base_len);
- ! if (pad_kind == (unsigned long)ios::internal)
- ! for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
- sbuf->sputn(buf, buf_len);
- ! if (pad_kind == (unsigned long)ios::left) // Left adjustment.
- ! for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
- stream.osfx();
- }
-
- --- 363,384 ----
-
- // Do actual output.
- register streambuf* sbuf = stream.rdbuf();
- ! ios::fmtflags pad_kind =
- stream.flags() & (ios::left|ios::right|ios::internal);
- char fill_char = stream.fill();
- ! if (padding > 0
- ! && pad_kind != (ios::fmtflags)ios::left
- ! && pad_kind != (ios::fmtflags)ios::internal) // Default (right) adjust.
- ! sbuf->padn(fill_char, padding);
- if (neg) sbuf->sputc('-');
- else if (show_pos) sbuf->sputc('+');
- if (show_base_len)
- sbuf->sputn(show_base, show_base_len);
- ! if (pad_kind == (ios::fmtflags)ios::internal && padding > 0)
- ! sbuf->padn(fill_char, padding);
- sbuf->sputn(buf, buf_len);
- ! if (pad_kind == (ios::fmtflags)ios::left && padding > 0) // Left adjustment
- ! sbuf->padn(fill_char, padding);
- stream.osfx();
- }
-
- ***************
- *** 445,454 ****
- // Uses __cvt_double (renamed from static cvt), in Chris Torek's
- // stdio implementation. The setup code uses the same logic
- // as in __vsbprintf.C (also based on Torek's code).
- - char negative;
- - char buf[BUF];
- int format_char;
- - int sign = '\0';
- #if 0
- if (os.flags() ios::showpos) sign = '+';
- #endif
- --- 429,435 ----
- ***************
- *** 469,474 ****
- --- 450,463 ----
- }
-
- // Do actual conversion.
- + #ifdef USE_DTOA
- + if (__outfloat(n, os.rdbuf(), format_char, os.width(0),
- + os.precision(), os.flags(), 0, os.fill()) < 0)
- + os.set(ios::badbit|ios::failbit); // ??
- + #else
- + int negative;
- + char buf[BUF];
- + int sign = '\0';
- char *cp = buf;
- *cp = 0;
- int size = __cvt_double(n, os.precision(),
- ***************
- *** 491,504 ****
- register streambuf* sbuf = os.rdbuf();
- register i;
- char fill_char = os.fill();
- ! unsigned long pad_kind =
- os.flags() & (ios::left|ios::right|ios::internal);
- ! if (pad_kind != (unsigned long)ios::left // Default (right) adjust.
- ! && pad_kind != (unsigned long)ios::internal)
- for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
- if (sign)
- sbuf->sputc(sign);
- ! if (pad_kind == (unsigned long)ios::internal)
- for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
-
- // Emit the actual concented field, followed by extra zeros.
- --- 480,493 ----
- register streambuf* sbuf = os.rdbuf();
- register i;
- char fill_char = os.fill();
- ! ios::fmtflags pad_kind =
- os.flags() & (ios::left|ios::right|ios::internal);
- ! if (pad_kind != (ios::fmtflags)ios::left // Default (right) adjust.
- ! && pad_kind != (ios::fmtflags)ios::internal)
- for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
- if (sign)
- sbuf->sputc(sign);
- ! if (pad_kind == (ios::fmtflags)ios::internal)
- for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
-
- // Emit the actual concented field, followed by extra zeros.
- ***************
- *** 505,512 ****
- sbuf->sputn(cp, size);
- for (i = fpprec; --i >= 0; ) sbuf->sputc('0');
-
- ! if (pad_kind == (unsigned long)ios::left) // Left adjustment
- for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
- os.osfx();
- }
- return os;
- --- 494,502 ----
- sbuf->sputn(cp, size);
- for (i = fpprec; --i >= 0; ) sbuf->sputc('0');
-
- ! if (pad_kind == (ios::fmtflags)ios::left) // Left adjustment
- for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
- + #endif
- os.osfx();
- }
- return os;
- ***************
- *** 557,580 ****
- return os;
- }
-
- ! ostream::ostream() : ios(¬_open_filebuf)
- ! {
- ! _flags |= ios::dont_close;
- ! _tie = NULL;
- ! }
- !
- ! ostream::ostream(streambuf* sb, ostream* tied) : ios(sb)
- ! {
- ! _flags |= ios::dont_close;
- ! _tie = tied;
- ! }
- !
- ! ostream::~ostream()
- {
- - if (!(_flags & (unsigned int)ios::dont_close))
- - delete _strbuf;
- _flags |= ios::dont_close;
- - _strbuf = ¬_open_filebuf;
- }
-
- ostream& ostream::seekp(streampos pos)
- --- 547,555 ----
- return os;
- }
-
- ! ostream::ostream(streambuf* sb, ostream* tied) : ios(sb, tied)
- {
- _flags |= ios::dont_close;
- }
-
- ostream& ostream::seekp(streampos pos)
- ***************
- *** 696,720 ****
- const unsigned long ios::adjustfield =
- ios::left|ios::right|ios::internal;
-
- ! iostream::iostream() : ios(¬_open_filebuf)
- {
- _flags |= ios::dont_close;
- _gcount = 0;
- - _tie = NULL;
- - }
- -
- - iostream::iostream(streambuf* sb, ostream* tied) : ios(sb)
- - {
- - _flags |= ios::dont_close;
- - _tie = tied;
- - }
- -
- - iostream::~iostream()
- - {
- - if (!(_flags & (unsigned int)ios::dont_close))
- - delete _strbuf;
- - _flags |= ios::dont_close;
- - _strbuf = ¬_open_filebuf;
- }
-
- ostream& iostream::form(const char *format ...) // Copy of ostream::form.
- --- 671,680 ----
- const unsigned long ios::adjustfield =
- ios::left|ios::right|ios::internal;
-
- ! iostream::iostream(streambuf* sb, ostream* tied) : ios(sb, tied)
- {
- _flags |= ios::dont_close;
- _gcount = 0;
- }
-
- ostream& iostream::form(const char *format ...) // Copy of ostream::form.
- ***************
- *** 730,736 ****
- if (ipfx0()) {
- va_list ap;
- va_start(ap, format);
- ! _strbuf->vscan(format, ap);
- va_end(ap);
- }
- return *this;
- --- 690,696 ----
- if (ipfx0()) {
- va_list ap;
- va_start(ap, format);
- ! _strbuf->vscan(format, ap, &_state);
- va_end(ap);
- }
- return *this;
- *** 1.5 1992/06/03 02:12:17
- --- mincl 1992/07/20 22:22:38
- ***************
- *** 18,24 ****
- IOSRC = editbuf.cc filebuf.cc fstream.cc igetline.cc indstrea.cc iostream.cc \
- makebuf.cc parsestr.cc sbufvfor.cc sbufvsca.cc sgetline.cc stdstrbu.cc \
- stdstrea.cc stream.cc streambu.cc strstrea.cc xplotfil.cc xsfile.cc \
- ! igetsb.cc
-
- #
- # NOTE:: dummy.o MUST be the last object on this list. otherwise you'll
- --- 18,24 ----
- IOSRC = editbuf.cc filebuf.cc fstream.cc igetline.cc indstrea.cc iostream.cc \
- makebuf.cc parsestr.cc sbufvfor.cc sbufvsca.cc sgetline.cc stdstrbu.cc \
- stdstrea.cc stream.cc streambu.cc strstrea.cc xplotfil.cc xsfile.cc \
- ! igetsb.cc iodtoa.cc outfloat.cc
-
- #
- # NOTE:: dummy.o MUST be the last object on this list. otherwise you'll
- *** 1.2 1992/06/03 02:12:17
- --- parsestr.cc 1992/07/20 22:22:39
- ***************
- *** 292,298 ****
- {
- #if 1
- abort();
- ! return 0; // fake the compiler
- #else
- if (i > 0) {
- size_t len = line_length();
- --- 292,298 ----
- {
- #if 1
- abort();
- ! return 0; // Suppress warning.
- #else
- if (i > 0) {
- size_t len = line_length();
- *** 1.5 1992/06/08 20:42:41
- --- regex.cc 1992/07/20 22:22:39
- ***************
- *** 287,293 ****
- necessary. */
- #define PATFETCH(c) \
- {if (p == pend) goto end_of_pattern; \
- ! c = * (unsigned char *) p++; \
- if (translate) c = translate[c]; }
-
- /* Fetch the next character in the uncompiled pattern, with no
- --- 287,293 ----
- necessary. */
- #define PATFETCH(c) \
- {if (p == pend) goto end_of_pattern; \
- ! c = * (const unsigned char *) p++; \
- if (translate) c = translate[c]; }
-
- /* Fetch the next character in the uncompiled pattern, with no
- ***************
- *** 294,300 ****
- translation. */
- #define PATFETCH_RAW(c) \
- {if (p == pend) goto end_of_pattern; \
- ! c = * (unsigned char *) p++; }
-
- #define PATUNFETCH p--
-
- --- 294,300 ----
- translation. */
- #define PATFETCH_RAW(c) \
- {if (p == pend) goto end_of_pattern; \
- ! c = * (const unsigned char *) p++; }
-
- #define PATUNFETCH p--
-
- ***************
- *** 385,394 ****
- re_compile_pattern (const char *pattern, int size, struct re_pattern_buffer *bufp)
- {
- register char *b = bufp->buffer;
- ! register char *p = pattern;
- ! char *pend = pattern + size;
- register unsigned c, c1;
- ! char *p1;
- unsigned char *translate = (unsigned char *) bufp->translate;
-
- /* Address of the count-byte of the most recently inserted `exactn'
- --- 385,394 ----
- re_compile_pattern (const char *pattern, int size, struct re_pattern_buffer *bufp)
- {
- register char *b = bufp->buffer;
- ! register const char *p = pattern;
- ! const char *pend = pattern + size;
- register unsigned c, c1;
- ! const char *p1;
- unsigned char *translate = (unsigned char *) bufp->translate;
-
- /* Address of the count-byte of the most recently inserted `exactn'
- ***************
- *** 429,435 ****
-
- /* Place in pattern (i.e., the {) to which to go back if the interval
- is invalid. */
- ! char *beg_interval = 0;
-
- /* Stack of information saved by \( and restored by \).
- Four stack elements are pushed by each \(:
- --- 429,435 ----
-
- /* Place in pattern (i.e., the {) to which to go back if the interval
- is invalid. */
- ! const char *beg_interval = 0;
-
- /* Stack of information saved by \( and restored by \).
- Four stack elements are pushed by each \(:
- ***************
- *** 479,485 ****
- {
- case '$':
- {
- ! char *p1 = p;
- /* When testing what follows the $,
- look past the \-constructs that don't consume anything. */
- if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS))
- --- 479,485 ----
- {
- case '$':
- {
- ! const char *p1 = p;
- /* When testing what follows the $,
- look past the \-constructs that don't consume anything. */
- if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS))
- *** 1.4 1992/06/03 02:12:17
- --- sbufvfor.cc 1992/07/20 22:22:39
- ***************
- *** 123,132 ****
-
- int streambuf::vform(char const *fmt0, _G_va_list ap)
- {
- ! register char *fmt; /* format string */
- register int ch; /* character from fmt */
- register int n; /* handy integer (short term usage) */
- register char *cp; /* handy char pointer (short term usage) */
- register int flags; /* flags as above */
- int ret; /* return value accumulator */
- int width; /* width from format (%8d), or 0 */
- --- 123,133 ----
-
- int streambuf::vform(char const *fmt0, _G_va_list ap)
- {
- ! register const char *fmt; /* format string */
- register int ch; /* character from fmt */
- register int n; /* handy integer (short term usage) */
- register char *cp; /* handy char pointer (short term usage) */
- + const char *fmark; /* for remembering a place in fmt */
- register int flags; /* flags as above */
- int ret; /* return value accumulator */
- int width; /* width from format (%8d), or 0 */
- ***************
- *** 133,139 ****
- int prec; /* precision from format (%.3d), or -1 */
- char sign; /* sign prefix (' ', '+', '-', or \0) */
- #ifdef FLOATING_POINT
- ! char softsign; /* temporary negative sign for floats */
- double _double; /* double precision arguments %[eEfgG] */
- int fpprec; /* `extra' floating precision in [eEfgG] */
- #endif
- --- 134,140 ----
- int prec; /* precision from format (%.3d), or -1 */
- char sign; /* sign prefix (' ', '+', '-', or \0) */
- #ifdef FLOATING_POINT
- ! int softsign; /* temporary negative sign for floats */
- double _double; /* double precision arguments %[eEfgG] */
- int fpprec; /* `extra' floating precision in [eEfgG] */
- #endif
- ***************
- *** 166,171 ****
- --- 167,176 ----
- #define PRINT(ptr, len) \
- do { if (sputn(ptr, len) != len) goto error; } while (0)
- #define FLUSH() { }
- + #if 1
- + #define PAD_SP(howmany) if (padn(' ', howmany) < 0) goto error;
- + #define PAD_0(howmany) if (padn('0', howmany) < 0) goto error;
- + #else
- #define PAD(howmany, with) { \
- if ((n = (howmany)) > 0) { \
- while (n > PADSIZE) { \
- ***************
- *** 175,180 ****
- --- 180,188 ----
- PRINT(with, n); \
- } \
- }
- + #define PAD_SP(howmany) PAD(howmany, blanks)
- + #define PAD_0(howmany) PAD(howmany, zeroes)
- + #endif
-
- /*
- * To extend shorts properly, we need both signed and unsigned
- ***************
- *** 193,199 ****
- if (unbuffered())
- return help_vform(this, fmt0, ap);
-
- ! fmt = (char *)fmt0;
- ret = 0;
-
- /*
- --- 201,207 ----
- if (unbuffered())
- return help_vform(this, fmt0, ap);
-
- ! fmt = fmt0;
- ret = 0;
-
- /*
- ***************
- *** 200,209 ****
- * Scan the format for conversions (`%' character).
- */
- for (;;) {
- ! for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++)
- /* void */;
- ! if ((n = fmt - cp) != 0) {
- ! PRINT(cp, n);
- ret += n;
- }
- if (ch == '\0')
- --- 208,217 ----
- * Scan the format for conversions (`%' character).
- */
- for (;;) {
- ! for (fmark = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++)
- /* void */;
- ! if ((n = fmt - fmark) != 0) {
- ! PRINT(fmark, n);
- ret += n;
- }
- if (ch == '\0')
- ***************
- *** 312,320 ****
- --- 320,346 ----
- case 'e':
- case 'E':
- case 'f':
- + case 'F':
- case 'g':
- case 'G':
- _double = va_arg(ap, double);
- + #ifdef USE_DTOA
- + {
- + ios::fmtflags fmt_flags = 0;
- + if (flags & ALT)
- + fmt_flags |= ios::showpoint;
- + if (flags & LADJUST)
- + fmt_flags |= ios::right;
- + if (__outfloat(_double, this, ch, width,
- + prec < 0 ? DEFPREC : prec,
- + fmt_flags,
- + sign,
- + flags & ZEROPAD ? '0' : ' ') < 0)
- + goto error;
- + }
- + // CHECK ERROR!
- + continue;
- + #else
- /*
- * don't do unrealistic precision; just pad it with
- * zeroes later, so buffer size stays rational.
- ***************
- *** 340,345 ****
- --- 366,372 ----
- if (*cp == '\0')
- cp++;
- break;
- + #endif
- #endif /* FLOATING_POINT */
- case 'n':
- if (flags & LONGINT)
- ***************
- *** 510,516 ****
-
- /* right-adjusting blank padding */
- if ((flags & (LADJUST|ZEROPAD)) == 0)
- ! PAD(width - realsz, blanks);
-
- /* prefix */
- if (sign) {
- --- 537,543 ----
-
- /* right-adjusting blank padding */
- if ((flags & (LADJUST|ZEROPAD)) == 0)
- ! PAD_SP(width - realsz);
-
- /* prefix */
- if (sign) {
- ***************
- *** 523,532 ****
-
- /* right-adjusting zero padding */
- if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
- ! PAD(width - realsz, zeroes);
-
- /* leading zeroes from decimal precision */
- ! PAD(dprec - fieldsz, zeroes);
-
- /* the string or number proper */
- PRINT(cp, size);
- --- 550,559 ----
-
- /* right-adjusting zero padding */
- if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
- ! PAD_0(width - realsz);
-
- /* leading zeroes from decimal precision */
- ! PAD_0(dprec - fieldsz);
-
- /* the string or number proper */
- PRINT(cp, size);
- ***************
- *** 533,544 ****
-
- #ifdef FLOATING_POINT
- /* trailing f.p. zeroes */
- ! PAD(fpprec, zeroes);
- #endif
-
- /* left-adjusting padding (always blank) */
- if (flags & LADJUST)
- ! PAD(width - realsz, blanks);
-
- /* finally, adjust ret */
- ret += width > realsz ? width : realsz;
- --- 560,571 ----
-
- #ifdef FLOATING_POINT
- /* trailing f.p. zeroes */
- ! PAD_0(fpprec);
- #endif
-
- /* left-adjusting padding (always blank) */
- if (flags & LADJUST)
- ! PAD_SP(width - realsz);
-
- /* finally, adjust ret */
- ret += width > realsz ? width : realsz;
- ***************
- *** 553,559 ****
- /* NOTREACHED */
- }
-
- ! #ifdef FLOATING_POINT
-
- static char *exponent(register char *p, register int exp, int fmtch)
- {
- --- 580,586 ----
- /* NOTREACHED */
- }
-
- ! #if defined(FLOATING_POINT) && !defined(USE_DTOA)
-
- static char *exponent(register char *p, register int exp, int fmtch)
- {
- ***************
- *** 584,590 ****
-
- static char * round(double fract, int *exp,
- register char *start, register char *end,
- ! char ch, char *signp)
- {
- double tmp;
-
- --- 611,617 ----
-
- static char * round(double fract, int *exp,
- register char *start, register char *end,
- ! char ch, int *signp)
- {
- double tmp;
-
- ***************
- *** 624,638 ****
- return (start);
- }
-
- ! int __cvt_double(double number, register int prec, int flags, char *signp,
- int fmtch, char *startp, char *endp)
- {
- register char *p, *t;
- register double fract;
- ! int dotrim, expcnt, gformat;
- double integer, tmp;
-
- ! dotrim = expcnt = gformat = 0;
- if (number < 0) {
- number = -number;
- *signp = '-';
- --- 651,665 ----
- return (start);
- }
-
- ! int __cvt_double(double number, register int prec, int flags, int *signp,
- int fmtch, char *startp, char *endp)
- {
- register char *p, *t;
- register double fract;
- ! int dotrim = 0, expcnt, gformat = 0;
- double integer, tmp;
-
- ! expcnt = 0;
- if (number < 0) {
- number = -number;
- *signp = '-';
- ***************
- *** 654,659 ****
- --- 681,687 ----
- }
- switch (fmtch) {
- case 'f':
- + case 'F':
- /* reverse integer into beginning of buffer */
- if (expcnt)
- for (; ++p < endp; *t++ = *p);
- ***************
- *** 812,815 ****
- return (t - startp);
- }
-
- ! #endif /* FLOATING_POINT */
- --- 840,843 ----
- return (t - startp);
- }
-
- ! #endif /* defined(FLOATING_POINT) && !defined(USE_DTOA) */
- *** 1.3 1992/06/03 02:12:17
- --- sbufvsca.cc 1992/07/20 22:22:40
- ***************
- *** 82,92 ****
- #define u_long unsigned long
-
- extern "C" u_long strtoul(const char*, char**, int);
- ! static u_char *__sccl(register char *tab, register u_char *fmt);
-
- ! int streambuf::vscan(char const *fmt0, _G_va_list ap)
- {
- ! register u_char *fmt = (u_char *)fmt0;
- register int c; /* character from format, or conversion */
- register size_t width; /* field width, or 0 */
- register char *p; /* points into all kinds of strings */
- --- 82,96 ----
- #define u_long unsigned long
-
- extern "C" u_long strtoul(const char*, char**, int);
- ! static const u_char *__sccl(register char *tab, register const u_char *fmt);
-
- ! // If state is non-NULL, set failbit and/or eofbit as appropriate.
- !
- ! int streambuf::vscan(char const *fmt0,
- ! _G_va_list ap,
- ! ios::iostate *state /* = NULL */)
- {
- ! register const u_char *fmt = (const u_char *)fmt0;
- register int c; /* character from format, or conversion */
- register size_t width; /* field width, or 0 */
- register char *p; /* points into all kinds of strings */
- ***************
- *** 101,106 ****
- --- 105,111 ----
- // conversion function (strtol/strtoul)
- char ccltab[256]; /* character class table for %[...] */
- char buf[BUF]; /* buffer for numeric conversions */
- + int seen_eof = 0;
-
- /* `basefix' is used to avoid `if' tests in the integer scanner */
- static short basefix[17] =
- ***************
- *** 111,122 ****
- for (;;) {
- c = *fmt++;
- if (c == 0)
- ! return (nassigned);
- if (isspace(c)) {
- for (;;) {
- c = sbumpc();
- if (c == EOF)
- ! return nassigned;
- if (!isspace(c)) {
- sputbackc(c);
- break;
- --- 116,127 ----
- for (;;) {
- c = *fmt++;
- if (c == 0)
- ! goto done;
- if (isspace(c)) {
- for (;;) {
- c = sbumpc();
- if (c == EOF)
- ! goto eof_failure;
- if (!isspace(c)) {
- sputbackc(c);
- break;
- ***************
- *** 139,145 ****
- literal:
- n = sbumpc();
- if (n == EOF)
- ! goto input_failure;
- if (n != c) {
- sputbackc(n);
- goto match_failure;
- --- 144,150 ----
- literal:
- n = sbumpc();
- if (n == EOF)
- ! goto eof_failure;
- if (n != c) {
- sputbackc(n);
- goto match_failure;
- ***************
- *** 259,265 ****
- * Disgusting backwards compatibility hacks. XXX
- */
- case '\0': /* compat */
- ! return (EOF);
-
- default: /* compat */
- if (isupper(c))
- --- 264,271 ----
- * Disgusting backwards compatibility hacks. XXX
- */
- case '\0': /* compat */
- ! nassigned = EOF;
- ! goto done;
-
- default: /* compat */
- if (isupper(c))
- ***************
- *** 274,280 ****
- * We have a conversion that requires input.
- */
- if (sgetc() == EOF)
- ! goto input_failure;
-
- /*
- * Consume leading white space, except for formats
- --- 280,286 ----
- * We have a conversion that requires input.
- */
- if (sgetc() == EOF)
- ! goto eof_failure;
-
- /*
- * Consume leading white space, except for formats
- ***************
- *** 287,293 ****
- nread++;
- n = sgetc();
- if (n == EOF)
- ! goto input_failure;
- }
- // Note that there is at least one character in
- // the buffer, so conversions that do not set NOSKIP
- --- 293,299 ----
- nread++;
- n = sgetc();
- if (n == EOF)
- ! goto eof_failure;
- }
- // Note that there is at least one character in
- // the buffer, so conversions that do not set NOSKIP
- ***************
- *** 301,307 ****
-
- case CT_CHAR:
- /* scan arbitrary characters (sets NOSKIP) */
- ! if (width == 0)
- width = 1;
- if (flags & SUPPRESS) {
- size_t sum = 0;
- --- 307,313 ----
-
- case CT_CHAR:
- /* scan arbitrary characters (sets NOSKIP) */
- ! if (width == 0) // FIXME!
- width = 1;
- if (flags & SUPPRESS) {
- size_t sum = 0;
- ***************
- *** 312,320 ****
- _gptr += n;
- if (underflow() == EOF)
- if (sum == 0)
- ! goto input_failure;
- ! else
- break;
- } else {
- sum += width;
- _gptr += width;
- --- 318,328 ----
- _gptr += n;
- if (underflow() == EOF)
- if (sum == 0)
- ! goto eof_failure;
- ! else {
- ! seen_eof++;
- break;
- + }
- } else {
- sum += width;
- _gptr += width;
- ***************
- *** 325,332 ****
- } else {
- size_t r = sgetn((char*)va_arg(ap, char*),
- width);
- ! if (r == 0)
- ! goto input_failure;
- nread += r;
- nassigned++;
- }
- --- 333,340 ----
- } else {
- size_t r = sgetn((char*)va_arg(ap, char*),
- width);
- ! if (r != width)
- ! goto eof_failure;
- nread += r;
- nassigned++;
- }
- ***************
- *** 345,351 ****
- break;
- if (sgetc() == EOF) {
- if (n == 0)
- ! goto input_failure;
- break;
- }
- }
- --- 353,360 ----
- break;
- if (sgetc() == EOF) {
- if (n == 0)
- ! goto eof_failure;
- ! seen_eof++;
- break;
- }
- }
- ***************
- *** 359,365 ****
- break;
- if (sgetc() == EOF) {
- if (p == p0)
- ! goto input_failure;
- break;
- }
- }
- --- 368,375 ----
- break;
- if (sgetc() == EOF) {
- if (p == p0)
- ! goto eof_failure;
- ! seen_eof++;
- break;
- }
- }
- ***************
- *** 382,389 ****
- n++, _gptr++;
- if (--width == 0)
- break;
- ! if (sgetc() == EOF)
- ! break;
- }
- nread += n;
- } else {
- --- 392,401 ----
- n++, _gptr++;
- if (--width == 0)
- break;
- ! if (sgetc() == EOF) {
- ! seen_eof++;
- ! break;
- ! }
- }
- nread += n;
- } else {
- ***************
- *** 392,399 ****
- *p++ = *_gptr++;
- if (--width == 0)
- break;
- ! if (sgetc() == EOF)
- ! break;
- }
- *p = 0;
- nread += p - p0;
- --- 404,413 ----
- *p++ = *_gptr++;
- if (--width == 0)
- break;
- ! if (sgetc() == EOF) {
- ! seen_eof++;
- ! break;
- ! }
- }
- *p = 0;
- nread += p - p0;
- ***************
- *** 499,507 ****
- */
- *p++ = c;
- _gptr++;
- ! if (sgetc() == EOF)
- ! break; /* EOF */
- ! }
- /*
- * If we had only a sign, it is no good; push
- * back the sign. If the number ends in `x',
- --- 513,523 ----
- */
- *p++ = c;
- _gptr++;
- ! if (sgetc() == EOF) {
- ! seen_eof++;
- ! break; /* EOF */
- ! }
- ! }
- /*
- * If we had only a sign, it is no good; push
- * back the sign. If the number ends in `x',
- ***************
- *** 589,596 ****
- fok:
- *p++ = c;
- _gptr++;
- ! if (sgetc() == EOF)
- ! break; /* EOF */
- }
- /*
- * If no digits, might be missing exponent digits
- --- 605,614 ----
- fok:
- *p++ = c;
- _gptr++;
- ! if (sgetc() == EOF) {
- ! seen_eof++;
- ! break; /* EOF */
- ! }
- }
- /*
- * If no digits, might be missing exponent digits
- ***************
- *** 614,622 ****
- }
- if ((flags & SUPPRESS) == 0) {
- double res;
- -
- *p = 0;
- res = atof(buf);
- if (flags & LONG)
- *va_arg(ap, double *) = res;
- else
- --- 632,643 ----
- }
- if ((flags & SUPPRESS) == 0) {
- double res;
- *p = 0;
- + #ifdef USE_DTOA
- + res = strtod(buf, NULL);
- + #else
- res = atof(buf);
- + #endif
- if (flags & LONG)
- *va_arg(ap, double *) = res;
- else
- ***************
- *** 628,636 ****
- #endif /* FLOATING_POINT */
- }
- }
- input_failure:
- ! return (nassigned ? nassigned : -1);
- match_failure:
- return (nassigned);
- }
-
- --- 649,665 ----
- #endif /* FLOATING_POINT */
- }
- }
- + eof_failure:
- + seen_eof++;
- input_failure:
- ! if (nassigned == 0)
- ! nassigned = -1;
- match_failure:
- + if (state)
- + *state |= ios::failbit;
- + done:
- + if (state && seen_eof)
- + *state |= ios::eofbit;
- return (nassigned);
- }
-
- ***************
- *** 640,646 ****
- * closing `]'. The table has a 1 wherever characters should be
- * considered part of the scanset.
- */
- ! static u_char *__sccl(register char *tab, register u_char *fmt)
- {
- register int c, n, v;
-
- --- 669,675 ----
- * closing `]'. The table has a 1 wherever characters should be
- * considered part of the scanset.
- */
- ! static const u_char *__sccl(register char *tab, register const u_char *fmt)
- {
- register int c, n, v;
-
- *** 1.4 1992/06/03 02:12:17
- --- streambu.cc 1992/07/20 22:22:41
- ***************
- *** 193,198 ****
- --- 193,201 ----
- size_t streambuf::sputn(const char* s, size_t n) // OPTIMIZE THIS!
- {
- size_t count = 0;
- +
- + if(((long)n) < 0) return 0;
- +
- for (; count < n; count++) {
- if (sputc(*s++) == EOF)
- break;
- ***************
- *** 224,229 ****
- --- 227,234 ----
- #else
- size_t streambuf::sputn(register const char* s, size_t n)
- {
- + if (n <= 0)
- + return 0;
- register size_t more = n;
- for (;;) {
- size_t count = _epptr - _pptr; // Space available.
- ***************
- *** 251,256 ****
- --- 256,262 ----
- return n - more;
- }
-
- +
- size_t streambuf::sgetn(char* s, size_t n)
- {
- register size_t more = n;
- ***************
- *** 297,302 ****
- --- 303,335 ----
- }
- #endif /* atari */
-
- + int streambuf::padn(char pad, int count)
- + {
- + #define PADSIZE 16
- + static char const blanks[PADSIZE] =
- + {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
- + static char const zeroes[PADSIZE] =
- + {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
- + char padbuf[PADSIZE];
- + const char *padptr;
- + register int i;
- +
- + if (pad == ' ')
- + padptr = blanks;
- + else if (pad == '0')
- + padptr = zeroes;
- + else {
- + for (i = PADSIZE; --i >= 0; ) padbuf[i] = pad;
- + padptr = padbuf;
- + }
- + for (i = count; i >= PADSIZE; i -= PADSIZE)
- + if (sputn(padptr, PADSIZE) != PADSIZE)
- + return EOF;
- + if (i > 0 && sputn(padptr, i) != i)
- + return EOF;
- + return pad;
- + }
- +
- int streambuf::sync()
- {
- if (gptr() == egptr() && pptr() == pbase())
- ***************
- *** 430,435 ****
- --- 463,469 ----
- {
- if (gptr() <= eback()) return pbackfail(c);
- gbump(-1);
- + // Don't write into the get buffer if we don't have to.
- if (*gptr() != c)
- *gptr() = c;
- return (unsigned char)c;
- ***************
- *** 654,659 ****
- --- 688,697 ----
- return start + count;
- }
-
- +
- + #if defined(linux)
- + #define IO_CLEANUP ;
- + #endif
-
- #ifdef IO_CLEANUP
- IO_CLEANUP
- *** 1.5 1992/06/03 02:12:17
- --- strstrea.cc 1992/07/20 22:22:41
- ***************
- *** 128,134 ****
- strstreambuf::strstreambuf()
- {
- _frozen = 0;
- - // _flags &= ~ios::dont_close;
- _len = 0;
- _size = 128;
- _buffer = ALLOC_BUF(_size);
- --- 128,133 ----
- ***************
- *** 140,146 ****
- strstreambuf::strstreambuf(int initial)
- {
- _frozen = 0;
- - // _flags &= ~ios::dont_close;
- _len = 0;
- if (initial < 16)
- initial = 16;
- --- 139,144 ----
- ***************
- *** 153,159 ****
-
- strstreambuf::strstreambuf(char *ptr, size_t size, char *pstart)
- {
- - // _flags &= ~ios::dont_close;
- _frozen = 1;
- if (size == 0)
- _size = strlen(ptr);
- --- 151,156 ----
- *** 1.3 1992/06/08 20:42:41
- --- timer.cc 1992/07/20 22:22:41
- ***************
- *** 32,39 ****
-
- #include <g_config.h>
- #include <osfcn.h>
- ! #if !defined(_G_HAVE_SYS_RESOURCE) || !defined(RUSAGE_SELF)
- #define USE_TIMES
- #include <sys/times.h>
- #if !defined (HZ) && defined(CLK_TCK)
- #define HZ CLK_TCK
- --- 32,40 ----
-
- #include <g_config.h>
- #include <osfcn.h>
- ! #if !_G_HAVE_SYS_RESOURCE || !defined(RUSAGE_SELF)
- #define USE_TIMES
- + #include <sys/param.h>
- #include <sys/times.h>
- #if !defined (HZ) && defined(CLK_TCK)
- #define HZ CLK_TCK
- *** 1.5 1992/06/03 02:12:17
- --- xbitset.cc 1992/07/20 22:22:42
- ***************
- *** 24,30 ****
- #endif
- #include <xbitset.h>
- #include <std.h>
- ! #include <values.h>
- #include <xobstack.h>
- #include <xallocri.h>
- #include <new.h>
- --- 24,30 ----
- #endif
- #include <xbitset.h>
- #include <std.h>
- ! #include <limits.h>
- #include <xobstack.h>
- #include <xallocri.h>
- #include <new.h>
- ***************
- *** 42,48 ****
- BitSetRep _nilBitSetRep = { 0, 1, 0, {0} }; // nil BitSets point here
-
- #define ONES ((unsigned short)(~0L))
- ! #define MAXBitSetRep_SIZE ((1 << (SHORTBITS - 1)) - 1)
- #define MINBitSetRep_SIZE 16
-
- #ifndef MALLOC_MIN_OVERHEAD
- --- 42,48 ----
- BitSetRep _nilBitSetRep = { 0, 1, 0, {0} }; // nil BitSets point here
-
- #define ONES ((unsigned short)(~0L))
- ! #define MAXBitSetRep_SIZE ((1 << (sizeof(short)*CHAR_BIT - 1)) - 1)
- #define MINBitSetRep_SIZE 16
-
- #ifndef MALLOC_MIN_OVERHEAD
- *** 1.4 1992/06/03 02:12:17
- --- xbitstri.cc 1992/07/20 22:22:42
- ***************
- *** 24,30 ****
- #endif
- #include <xbitstri.h>
- #include <std.h>
- ! #include <values.h>
- #include <xobstack.h>
- #include <xallocri.h>
- #include <new.h>
- --- 24,30 ----
- #endif
- #include <xbitstri.h>
- #include <std.h>
- ! #include <limits.h>
- #include <xobstack.h>
- #include <xallocri.h>
- #include <new.h>
- ***************
- *** 43,49 ****
- BitString _nil_BitString;
-
- #define MINBitStrRep_SIZE 8
- ! #define MAXBitStrRep_SIZE ((1 << (SHORTBITS - 1)) - 1)
-
- #ifndef MALLOC_MIN_OVERHEAD
- #define MALLOC_MIN_OVERHEAD 4
- --- 43,49 ----
- BitString _nil_BitString;
-
- #define MINBitStrRep_SIZE 8
- ! #define MAXBitStrRep_SIZE ((1 << (sizeof(short)*CHAR_BIT - 1)) - 1)
-
- #ifndef MALLOC_MIN_OVERHEAD
- #define MALLOC_MIN_OVERHEAD 4
- ***************
- *** 148,154 ****
- if (ss != ds)
- {
- int n = (unsigned)(nbits) / BITSTRBITS;
- ! if (n > 0) bcopy((void*)ss, (void*)ds, n * sizeof(short));
- unsigned short m = ONES << (nbits & (BITSTRBITS - 1));
- ds[n] = (ss[n] & ~m) | (ds[n] & m);
- }
- --- 148,154 ----
- if (ss != ds)
- {
- int n = (unsigned)(nbits) / BITSTRBITS;
- ! if (n > 0) memmove((void*)ds, (const void*)ss, n * sizeof(short));
- unsigned short m = ONES << (nbits & (BITSTRBITS - 1));
- ds[n] = (ss[n] & ~m) | (ds[n] & m);
- }
- ***************
- *** 1973,1979 ****
-
- void BitString::printon(ostream& os, char f, char t) const
- {
- - size_t wrksiz = length() + 2;
- size_t xl = rep->len;
- const unsigned short* ptr = rep->s;
- register streambuf *sb = os.rdbuf();
- --- 1973,1978 ----
- ***************
- *** 1992,1998 ****
- {
- size_t wrksiz = x.length() + 2;
- char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- - char* fmt = fmtbase;
- ostrstream stream(fmtbase, wrksiz);
-
- x.printon(stream, f, t);
- --- 1991,1996 ----
- *** 1.1 1992/03/22 07:42:32
- --- xgetopt.cc 1992/07/20 22:22:44
- ***************
- *** 19,24 ****
- --- 19,34 ----
- #ifdef __GNUG__
- #pragma implementation
- #endif
- + /* AIX requires the alloca decl to be the first thing in the file. */
- + #ifdef __GNUC__
- + #define alloca __builtin_alloca
- + #elif defined(sparc)
- + #include <alloca.h>
- + #elif defined(_AIX)
- + #pragma alloca
- + #else
- + char *alloca ();
- + #endif
- #include <xgetopt.h>
-
- char* GetOpt::nextchar = 0;
- *** 1.5 1992/06/03 02:12:17
- --- xinteger.cc 1992/07/20 22:22:44
- ***************
- *** 32,38 ****
- #include <std.h>
- #include <ctype.h>
- #include <math.h>
- ! #include <values.h>
- #include <xobstack.h>
- #include <xallocri.h>
- #include <new.h>
- --- 32,38 ----
- #include <std.h>
- #include <ctype.h>
- #include <math.h>
- ! #include <limits.h>
- #include <xobstack.h>
- #include <xallocri.h>
- #include <new.h>
- ***************
- *** 44,50 ****
- as unsigned shorts is changed in the implementation files.
- */
-
- ! #define I_SHIFT SHORTBITS
- #define I_RADIX ((unsigned long)(1L << I_SHIFT))
- #define I_MAXNUM ((unsigned long)((I_RADIX - 1)))
- #define I_MINNUM ((unsigned long)(I_RADIX >> 1))
- --- 44,50 ----
- as unsigned shorts is changed in the implementation files.
- */
-
- ! #define I_SHIFT (sizeof(short) * CHAR_BIT)
- #define I_RADIX ((unsigned long)(1L << I_SHIFT))
- #define I_MAXNUM ((unsigned long)((I_RADIX - 1)))
- #define I_MINNUM ((unsigned long)(I_RADIX >> 1))
- ***************
- *** 52,59 ****
- #define I_NEGATIVE 0
-
- /* All routines assume SHORT_PER_LONG > 1 */
- ! #define SHORT_PER_LONG ((unsigned)(((LONGBITS + SHORTBITS - 1) / SHORTBITS)))
- ! #define CHAR_PER_LONG ((unsigned)(((LONGBITS + CHARBITS - 1) / CHARBITS)))
-
- /*
- minimum and maximum sizes for an IntRep
- --- 52,59 ----
- #define I_NEGATIVE 0
-
- /* All routines assume SHORT_PER_LONG > 1 */
- ! #define SHORT_PER_LONG ((unsigned)(((sizeof(long) + sizeof(short) - 1) / sizeof(short))))
- ! #define CHAR_PER_LONG ((unsigned)sizeof(long))
-
- /*
- minimum and maximum sizes for an IntRep
- ***************
- *** 349,355 ****
- long Itolong(const IntRep* rep)
- {
- if ((unsigned)(rep->len) > (unsigned)(SHORT_PER_LONG))
- ! return (rep->sgn == I_POSITIVE) ? MAXLONG : MINLONG;
- else if (rep->len == 0)
- return 0;
- else if ((unsigned)(rep->len) < (unsigned)(SHORT_PER_LONG))
- --- 349,355 ----
- long Itolong(const IntRep* rep)
- {
- if ((unsigned)(rep->len) > (unsigned)(SHORT_PER_LONG))
- ! return (rep->sgn == I_POSITIVE) ? LONG_MAX : LONG_MIN;
- else if (rep->len == 0)
- return 0;
- else if ((unsigned)(rep->len) < (unsigned)(SHORT_PER_LONG))
- ***************
- *** 366,372 ****
- {
- unsigned long a = rep->s[SHORT_PER_LONG - 1];
- if (a >= I_MINNUM)
- ! return (rep->sgn == I_POSITIVE) ? MAXLONG : MINLONG;
- else
- {
- a = up(a) | rep->s[SHORT_PER_LONG - 2];
- --- 366,372 ----
- {
- unsigned long a = rep->s[SHORT_PER_LONG - 1];
- if (a >= I_MINNUM)
- ! return (rep->sgn == I_POSITIVE) ? LONG_MAX : LONG_MIN;
- else
- {
- a = up(a) | rep->s[SHORT_PER_LONG - 2];
- ***************
- *** 381,387 ****
- }
-
- // test whether op long() will work.
- ! // careful about asymmetry between MINLONG & MAXLONG
-
- int Iislong(const IntRep* rep)
- {
- --- 381,387 ----
- }
-
- // test whether op long() will work.
- ! // careful about asymmetry between LONG_MIN & LONG_MAX
-
- int Iislong(const IntRep* rep)
- {
- ***************
- *** 1806,1812 ****
- return r;
- }
-
- ! void setbit(Integer& x, long b)
- {
- if (b >= 0)
- {
- --- 1806,1812 ----
- return r;
- }
-
- ! void (setbit)(Integer& x, long b)
- {
- if (b >= 0)
- {
- *** 1.2 1992/05/31 04:14:02
- --- xstring.cc 1992/07/20 22:22:46
- ***************
- *** 25,31 ****
- #include <xstring.h>
- #include <std.h>
- #include <ctype.h>
- ! #include <values.h>
- #include <new.h>
- #include <builtin.h>
-
- --- 25,31 ----
- #include <xstring.h>
- #include <std.h>
- #include <ctype.h>
- ! #include <limits.h>
- #include <new.h>
- #include <builtin.h>
-
- ***************
- *** 109,115 ****
-
- // minimum & maximum representable rep size
-
- ! #define MAXStrRep_SIZE ((1 << (SHORTBITS - 1)) - 1)
- #define MINStrRep_SIZE 16
-
- #ifndef MALLOC_MIN_OVERHEAD
- --- 109,115 ----
-
- // minimum & maximum representable rep size
-
- ! #define MAXStrRep_SIZE ((1 << (sizeof(short) * CHAR_BIT - 1)) - 1)
- #define MINStrRep_SIZE 16
-
- #ifndef MALLOC_MIN_OVERHEAD
-